"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

var Item = /*#__PURE__*/function (_React$Component) {
  _inherits(Item, _React$Component);

  var _super = _createSuper(Item);

  function Item(props) {
    var _this;

    _classCallCheck(this, Item);

    _this = _super.call(this, props);
    _this._measure = _this._measure.bind(_assertThisInitialized(_this));
    return _this;
  }

  _createClass(Item, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      this.props.measure();
    }
  }, {
    key: "_measure",
    value: function _measure() {
      this.props.measure();
    }
  }, {
    key: "render",
    value: function render() {
      var _item$question,
          _item$question$beUser,
          _item$user,
          _this2 = this;

      var item = this.props.data;
      return /*#__PURE__*/_react.default.createElement("div", {
        className: "list-item"
      }, /*#__PURE__*/_react.default.createElement("div", {
        className: "list-item-h"
      }, /*#__PURE__*/_react.default.createElement("div", {
        className: "img"
      }, item.user.avatarUrl && item.user.avatarUrl !== '' ? /*#__PURE__*/_react.default.createElement("img", {
        alt: "\u56FE\u7247",
        src: item.type === 5 && item.question && item.question.is_answer === 1 && item.question.beUser ? item.question.beUser.avatarUrl : item.user.avatarUrl
      }) : /*#__PURE__*/_react.default.createElement("div", {
        className: "default-avatar"
      }, item.user.username[0].toUpperCase())), /*#__PURE__*/_react.default.createElement("div", {
        className: "info"
      }, /*#__PURE__*/_react.default.createElement("p", {
        className: "name"
      }, item.type === 5 && item.question && item.question.is_answer === 1 && item.question.beUser ? item.question.beUser.username : item.user.username), /*#__PURE__*/_react.default.createElement("div", {
        className: "sub-box"
      }, /*#__PURE__*/_react.default.createElement("p", {
        className: "date"
      }, "2021-11-11 14:22:22"), item.type == '5' && /*#__PURE__*/_react.default.createElement("div", {
        className: "question-box"
      }, item.question && item.question.is_answer === 0 && /*#__PURE__*/_react.default.createElement("div", {
        className: "question-box-content"
      }, "\u5411", /*#__PURE__*/_react.default.createElement("span", null, "@", ((_item$question = item.question) === null || _item$question === void 0 ? void 0 : (_item$question$beUser = _item$question.beUser) === null || _item$question$beUser === void 0 ? void 0 : _item$question$beUser.username) || '匿名用户'), "\u63D0\u95EE\uFF1A"), item.question && item.question.is_answer === 1 && /*#__PURE__*/_react.default.createElement("div", {
        className: "question-box-content"
      }, "\u56DE\u7B54\u4E86", /*#__PURE__*/_react.default.createElement("span", null, "@", ((_item$user = item.user) === null || _item$user === void 0 ? void 0 : _item$user.username) || '匿名用户'), "\u7684\u63D0\u95EE\uFF1A"))))), /*#__PURE__*/_react.default.createElement("div", {
        className: "list-item-content"
      }, item.type == 1 ? /*#__PURE__*/_react.default.createElement("div", {
        className: "title"
      }, "\u53D1\u5E03\u4E86\uFF1A", /*#__PURE__*/_react.default.createElement("span", null, item.title)) : /*#__PURE__*/_react.default.createElement("div", {
        className: "body"
      }, item.firstPost.summary_component), item.firstPost.images && item.firstPost.images.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
        className: "image-list"
      }, item.firstPost.images.slice(0, 9).map(function (data, key) {
        return /*#__PURE__*/_react.default.createElement("div", {
          className: "image-item image-count-".concat(item.firstPost.images.length >= 3 ? 3 : item.firstPost.images.length),
          style: {
            backgroundImage: "url(".concat(data.thumbUrl, ")")
          },
          key: key
        }, /*#__PURE__*/_react.default.createElement("img", {
          onLoad: function onLoad() {
            item.firstPost.images.length == 1 && _this2._measure();
          },
          src: data.thumbUrl,
          alt: "\u56FE\u7247"
        }));
      })), item.type === 2 && item.threadVideo && /*#__PURE__*/_react.default.createElement("div", {
        className: "video-main"
      }, /*#__PURE__*/_react.default.createElement("img", {
        className: "play",
        src: "/video.svg",
        alt: "\u56FE\u7247"
      }), /*#__PURE__*/_react.default.createElement("div", {
        className: "bgimg",
        style: {
          backgroundImage: "url(".concat(item.threadVideo.cover_url, ")")
        }
      }))), /*#__PURE__*/_react.default.createElement("div", {
        className: "list-item-f"
      }, /*#__PURE__*/_react.default.createElement("div", {
        className: "item"
      }, /*#__PURE__*/_react.default.createElement("p", {
        className: "qui-icon icon-like"
      }), /*#__PURE__*/_react.default.createElement("p", null, "\u8D5E", item.firstPost.likeCount || '')), /*#__PURE__*/_react.default.createElement("div", {
        className: "item"
      }, /*#__PURE__*/_react.default.createElement("p", null, "\u8BC4\u8BBA")), /*#__PURE__*/_react.default.createElement("div", {
        className: "item"
      }, /*#__PURE__*/_react.default.createElement("p", {
        className: "qui-icon icon-share"
      }), /*#__PURE__*/_react.default.createElement("p", null, "\u5206\u4EAB"))));
    }
  }]);

  return Item;
}(_react.default.Component);

exports.default = Item;